package fm.last.api
{
    import flash.net.URLRequestMethod;
    import flash.net.URLVariables;
    
    import fm.last.Agent;
    import fm.last.RestAPI;
    
    final public class VenueAPI extends RestAPI
    {
        // those in comment are not implemented yet
        public static const VENUE_GET_EVENTS:String      = "venue.getEvents";
        public static const VENUE_GET_PAST_EVENTS:String = "venue.getPastEvents";
        public static const VENUE_SEARCH:String          = "venue.search";
        
        public function VenueAPI(agent:Agent)
        {
            super(agent);
        }

        /* ********************************************************************/
        

        /** venue.getEvents */
        public function getEvents(onComplete:Function, 
                                   onError:Function,
                                   venue:String):void
        {
            var urlVars:URLVariables = new URLVariables();
            urlVars["method"] = VenueAPI.VENUE_GET_EVENTS;
            urlVars["venue"] = venue;
            requestAPI(URLRequestMethod.GET, urlVars, false, onComplete, onError);        
        }
        

        /** venue.getPastEvents */
        public function getPastEvents(onComplete:Function, 
                                   onError:Function,
                                   venue:String,
                                   page:int=-1,
                                   limit:int=-1):void
        {
            var urlVars:URLVariables = new URLVariables();
            urlVars["method"] = VenueAPI.VENUE_GET_PAST_EVENTS;
            urlVars["venue"] = venue;
            if (page>0) urlVars["page"] = page;
            if (limit>0) urlVars["limit"] = limit;
            requestAPI(URLRequestMethod.GET, urlVars, false, onComplete, onError);        
        }
        

        /** venue.search */
        public function search(onComplete:Function, 
                                   onError:Function,
                                   venue:String,
                                   country:String=null,
                                   page:int=-1,
                                   limit:int=-1):void
        {
            var urlVars:URLVariables = new URLVariables();
            urlVars["method"] = VenueAPI.VENUE_SEARCH;
            urlVars["venue"] = venue;
            if (country!=null) urlVars["country"] = country;
            if (page>0) urlVars["page"] = page;
            if (limit>0) urlVars["limit"] = limit;
            requestAPI(URLRequestMethod.GET, urlVars, false, onComplete, onError);        
        }
        

    }
}